package com.example.sqllite.sqliteroom;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

@Database(entities = {User.class}, version = 1)
public abstract class MyRoomDatabase extends RoomDatabase {
    private static MyRoomDatabase instance;

    public abstract UserDao UserDao();

    static MyRoomDatabase getInstance(Context context){
        if(instance == null){
            instance = Room.databaseBuilder(context.getApplicationContext(), MyRoomDatabase.class, "room")
                    .allowMainThreadQueries()
                    .build();
        }
        return instance;
    }
}
